package org.gfix.parser;

import java.io.StringReader;

import org.gfix.parser.FixHandler;
import org.gfix.parser.FixParser;
import org.gfix.parser.MessageSource;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.runner.RunWith;

@RunWith(JMock.class)
public class BaseParserTest
{
	protected Mockery context = new JUnit4Mockery();

	protected void runTest(final FixHandler handler, String message,final Expectations expect) throws Exception
	{
		MessageSource source = new MessageSource(new StringReader(message));
		FixParser fp = getParser();
		
		// set the expectations
		context.checking(expect);
		
		fp.parse(source, handler);	
	}
	
	protected FixParser getParser()
	{
		return  new FixParser();
	}
}
